package org.cytoscape.myapp.cytoscape_app_v1.internal.UI;

import org.cytoscape.myapp.cytoscape_app_v1.internal.UI.Constants.Selection;
import org.cytoscape.myapp.cytoscape_app_v1.internal.grupos.FactoryInterface;
import org.cytoscape.myapp.cytoscape_app_v1.internal.grupos.FactoryNoSensitive;
import org.cytoscape.myapp.cytoscape_app_v1.internal.grupos.FactorySensitive;
import org.cytoscape.myapp.cytoscape_app_v1.internal.grupos.factories.ConcreteComparadorIgual;
import org.cytoscape.myapp.cytoscape_app_v1.internal.grupos.factories.ConcreteCompardorContenido;
import org.cytoscape.myapp.cytoscape_app_v1.internal.grupos.factories.FactoryComparador;
import org.cytoscape.myapp.cytoscape_app_v1.internal.helpers.Utils;

public class SubComponentInfo {
	
	private FactoryComparador comparador;
	private FactoryInterface sensitive;
	private String[] words;

	
	public SubComponentInfo(SubComponent sub){
		
		Selection comparador =  (Selection) ((SubComponent) sub).getComboBoxComparator().getSelectedItem();
		switch (comparador) {
			case CONTAINS: {
				this.setComparador(new ConcreteCompardorContenido());
			}
			break;
			
			case EQUALS: {
				this.setComparador(new ConcreteComparadorIgual());
			}
			break;
		default:
			break;
	
		}
		
		if (sub.getChckbxCaseSensitiveCheckBox().isSelected())
			this.setSensitive(new FactorySensitive());
		else
			this.setSensitive(new FactoryNoSensitive());		
		
		 this.setWords(Utils.getPalabrasSeparadas(((SubComponent) sub).getTextFieldWords().getText()));
		
	}



	/**
	 * @return the comparador
	 */
	public FactoryComparador getComparador() {
		return comparador;
	}



	/**
	 * @param comparador the comparador to set
	 */
	public void setComparador(FactoryComparador comparador) {
		this.comparador = comparador;
	}



	/**
	 * @return the sensitive
	 */
	public FactoryInterface getSensitive() {
		return sensitive;
	}



	/**
	 * @param sensitive the sensitive to set
	 */
	public void setSensitive(FactoryInterface sensitive) {
		this.sensitive = sensitive;
	}



	/**
	 * @return the words
	 */
	public String[] getWords() {
		return words;
	}



	/**
	 * @param words the words to set
	 */
	public void setWords(String[] words) {
		this.words = words;
	}
	
	
	
}

